<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class Queue{
            #items = {};
            #lowCount = 0;
            #count = 0;

            enQueue(data){
                this.#items[this.#count] = data;
                this.#count++;
            }

            delQueue(){
                if(this.isEmpty()){
                    return;
                }
                let res = this.#items[this.#lowCount];
                delete this.#items[this.#lowCount];
                this.#lowCount++;
                return res;
            }

            front(){
                return this.#items[this.#lowCount]
            }

            isEmpty(){
                return this.size()==0
            }

            size(){
                return this.#count - this.#lowCount;
            }

            clear(){
                this.#items = {};
                this.#count = 0;
                this.#lowCount = 0;
            }

            toString(){
                let str = '';
                for(let i = this.#lowCount;i<this.#count;i++){
                    str+=`${this.#items[i]}`;
                }
                return str;
            }
        }

        let queue = new Queue();


        function game(arr,count){
            let queue = new Queue();

            for(let i = 0;i<arr.length;i++){
                queue.enQueue(arr[i]);
            }

            while(queue.size()>1){
                for(let i = 0;i<count;i++){
                    queue.enQueue(queue.delQueue())
                }
                console.log(queue.delQueue()+'出局了');
            }

            return queue.delQueue();

        }
        console.log(game(['xiaoming','mikaisa','lixinyu','wangjiaqi','liukang'],7)+'获胜了');
    </script>
</body>
</html>